package cn.tedu.service.cmn.listenter;

import cn.tedu.service.cmn.mapper.IDictMapper;
import cn.tedu.service.cmn.vo.Dict;
import cn.tedu.service.cmn.vo.DictStandardVO;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import org.springframework.beans.BeanUtils;


public class DictListener extends AnalysisEventListener<DictStandardVO> {
    //调入数据库,使用有参构造传入
    private IDictMapper dictMapper;

    public DictListener(IDictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    //一行一行的读取
    @Override
    public void invoke(DictStandardVO dictEeVo, AnalysisContext analysisContext) {
        //调用方法添加到数据库
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo,dict);
        dictMapper.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
